package com.spirng.leetcode.day06;

public class Test101 {
    public static void main(String[] args) {
        TreeNode root = new TreeNode(1,new TreeNode(2),new TreeNode(2));
        Test101 test101 = new Test101();
        test101.isSymmetric(root);
    }
    public boolean isSymmetric(TreeNode root) {
       return isSymmetricCup(root.left,root.right);
    }
    public boolean isSymmetricCup(TreeNode left,TreeNode right){
      if(left!=null&&right==null){
          return false;
      }
      if(left==null&&right!=null){
          return false;
      }
      if(left==null&&right==null){
          return true;
      }
      if(left.val!=right.val){
          return false;
      }


        boolean a = isSymmetricCup(left.left, right.right);
        boolean b=isSymmetricCup(left.right,right.left);
        return a&&b;
    }
}
